# 导包
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

# 打开浏览器
service = Service(r"D://Python314//chromedriver.exe")
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=service, options=chrome_options)   # 创建浏览器对象
# 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")
# 放大游览器页面
driver.maximize_window()
# 暂停3秒
time.sleep(30)
driver.set_window_size(800,600)   # 窗口尺寸像素800*600
time.sleep(30)
driver.set_window_position(0,500)   # 将窗口移至屏幕坐标0，500
time.sleep(30)
# 刷新
driver.refresh()

# 获取标题
print(driver.title)

# 获取网页地址
print(driver.current_url)

# ID选择器
# 标签元素有ID属性
# 写法： value="#id属性值"
driver.find_element(By.CSS_SELECTOR,"#userA").send_keys("admin")
# 属性选择器
# 写法： value="[属性名='属性值']"
# driver.find_element(By.CSS_SELECTOR,"[name='passwordA']").send_keys("123456")
# 类选择器
# 标签元素有class属性
# 写法： value=".class属性值"
# driver.find_element(By.CSS_SELECTOR,".telA").send_keys("13012345678")
# 多个class值，通过点号连接
#driver.find_element(By.CSS_SELECTOR,".emailA.dzyxA").send_keys("12345@qq.com")
# 标签选择器





# 暂停3秒
# time.sleep(30)
# 退出浏览器
# driver.quit()